var mongoose=require('mongoose')
var db=require('./mongoose_db.js')

var studentSchema=new mongoose.Schema({                   //（模式）数据类型  不是模型
    name:String,
    author:String
})

var studentSchema2=new mongoose.Schema({                   //（模式）数据类型  不是模型
    name:{
        age:String,
        haha:Number
    }
    
})




studentSchema.statics.zhaoren=function(name,callback){          //这是静态方法
    return this.model('Student').find({name:name},callback)
}
studentSchema.methods.hehe=function(name,callback){             //这是对象方法（静态方法）
    return this.model('Student').find({name:name},callback)
}

studentSchema.index({name:1})                                    //创建索引



var studentModel=db.model('Student',studentSchema)              //生成类

var aa=new studentModel({                                       //实例
    name:"蒙哥",
    author:"aaa"
})




module.exports=studentModel


